package com.sloera.spring.jdbc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

/**
 * @author sloera
 * @create 2020/4/10
 */
@Repository
public class PaymentDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public PaymentBean get(Integer id) {
        String sql = "select id, serial from payment where id = ?";
        RowMapper<PaymentBean> rowMapper = new BeanPropertyRowMapper<>(PaymentBean.class);
        PaymentBean paymentBean = jdbcTemplate.queryForObject(sql, rowMapper, id);
        return paymentBean;
    }
}
